
#include <BGridLayout>
#include <BVBoxLayout>
#include <BHBoxLayout>
#include <BLabel>
#include <BListItem>
#include <BShape>
#include <BNode>
#include <BStyle>

#include "GroupPanel.h"

GroupPanel::GroupPanel(BWidget* parent) : BGroupBox(parent)
{
	this->setTitle("Group");

	_group = 0;

	BGridLayout* topLayout = new BGridLayout(this);
	{
		BLabel* visibleLabel = new BLabel("Visible");
		_visibleCheckBox = new BCheckBox();
		topLayout->addWidget(0, 0, visibleLabel);
		topLayout->addWidget(0, 1, _visibleCheckBox);
	}

	connect(this, Signal_AssetChanged, &GroupPanel::slotAssetChanged);
	connect(_visibleCheckBox, Signal_Toggled, &GroupPanel::slotVisibleCheckBoxToggled);

}
GroupPanel::~GroupPanel()
{

}

void GroupPanel::slotAssetChanged(BObject* object, const BValue& value)
{
	_group = value;
	if (_group)
	{
		_visibleCheckBox->setChecked(_group->visible());
	}
}
void GroupPanel::slotVisibleCheckBoxToggled(BObject* object, const BValue& value)
{
	bool visible = value;
	_group->setVisible(visible);
	if (visible)
		emit("object-shown", _group);
	else
		emit("object-hidden", _group);
}

void GroupPanel::styleEvent(const BEvent& event)
{
	BGroupBox::styleEvent(event);
}
